/**
* @file			main.c
* @author  		Supachai Vorapojpisut
* @version 		1.0
* @date    		November 11, 2013
* @brief   		Template code for main program.
*/

/* Includes ------------------------------------------------------------------*/
#include "arduino.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/


/**
* @brief	The setup() function will only run once, after each powerup or reset of the board. Use it to initialize variables, pin modes, start using libraries, etc.
* @param	None
* @retval	None
*/
void setup()
{
	Serial.begin(9600);
}


/**
* @brief	The loop() function does loop consecutively, allowing your program to change and respond. Use it to actively control the board.
* @param	None
* @retval	None
*/
uint8_t gotPinDigit1= 0;
uint8_t gotPinDigit2= 0;
void loop()
{
	char buf[20];
	int i;
	
	if (Serial.available()) {
		i = 0;
		do {
			buf[i++] = Serial.read();
			
			if (buf[i] == 0x11)
			
			{
				gotPinDigit2= 1;
				
			}
			if (i==0)
					continue;
			 if (buf[i-1] == 0x25)
				 gotPinDigit1= 1;
			 if (gotPinDigit1 && gotPinDigit2)
			 { 
				 
			 Serial.println("Got the pin number");
				 gotPinDigit1 = 0;
				 gotPinDigit2= 0;
				 
				 
			 }
			 else
				 Serial.println("Test Fail");
			 
			 if (i==20) i = 0;
			 
		} 
		while(Serial.available());
		buf[i] = 0;
	
	} 
	delay(500);
}


/**
* @brief	Template main function
* @param	None
* @retval	None
*/
int main() 
{
	platform_config();
	setup();
	while(1) {
		loop();
	}
}
